import { observable } from "mobx"
// import { math } from "@/utils/math"

/**
 * 商品
 */

export interface IGood {

    id: number
    name: string
    // desc?: string
    price: number
    nick?: string
    brief: string
    cost_price: number
    main_pic: string
    market_price: number
    dis?: number
    num?: number
}

export type Banner = {
    url: string
    req?: string
}


export enum RequestType {
    NAV = 'navigateTo',
    REQ = 'redirectTo',
    TAB = 'switchTab',
    H5 = 'mobile',
    SCAN = 'scanCode'
}

export enum Target {
    CATE = 'CATE',
    GOODS = 'GOODS',
    PAGES = 'PAGES',
    SCAN = 'SCAN',
    H5 = 'H5'
}

export type Menu = {
    name: string
    icon?: string
    image_url?: string
    requestType?: RequestType
    color?: string
    category_id?: number
    gid?: number,
    target?: Target,
    param?: string


}

export enum IGoodsType {
    SCROLL = 'SCROLL',
    ONE = 'ONE',
    TWO = 'TWO',
    ACTIVITY = 'ACTIVITY'
}


export type IGoodList = {
    items: IGood[]
    title: string
    type: IGoodsType
    number: number
}

export type SideBarItem = {
    title: string
    dot?: boolean
    info?: string
    disabled: boolean
    active?: boolean
    id: string | number
}


export type CartItemModel = {
    Good: IGood,
    number: number
}

export type OrderItemModel = {
    order_goods: IGood,
    status: string,
    statusText: string,
    order_id: string,
    all_price: number,
    create_time: string,
    people_number: number,
    number: number
}

export type PayData = {
    appid: string
    prepay_id: string
}

export enum ShopType {
    OTHER = 'OTHER',
    CATERING = 'CATERING'
}

export type ShopDetail = {
    about: string,
    address: string,
    name: string,
    phone: string,
    type?: ShopType | undefined
}


export class Good implements IGood {

    id: number
    name: string
    // desc?: string
    price: number
    nick?: string
    brief: string
    cost_price: number
    main_pic: string
    market_price: number
    dis?: number

    @observable
    num?: number
    constructor(id, name, nick, brief, price, cost_price, main_pic, market_price, dis, num) {

        this.id = id
        this.name = name
        this.nick = nick
        this.brief = brief
        this.cost_price = cost_price
        this.main_pic = main_pic
        this.market_price = market_price
        this.dis = dis
        this.price = price
        this.num = num

    }


}
